<?php
namespace Admin\Controller;
use Think\Controller;
use Admin\Controller\CommonController;
class Tree extends CommonController {
	public $tempArr = array();
	public function run($res, $fid=0 , $level=-1)
	{
		$level++;
		foreach ($res as $row) {
			if($row['fid']==$fid){
				// $row['cname'] = $level.$row['cname'];
				$row['cname'] = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;',$level).'┣'.$row['cname'];
				$this->tempArr[]=$row;
				$this->run($res,$row['id'],$level);
			}
		}

		return $this->tempArr; 
	}

	public function run1($res, $fid=0)
	{
		$tempArr = array();
		foreach ($res as $row) {
			if($row['fid']==$fid){
				$row['son']=$this->run1($res,$row['id']);
				$tempArr[]=$row;
			}
		}

		return $tempArr; 
	}
}